/* $RCSFile: AddEditItemPage.cs $
 * Apache license v2 2011 by Christian Surieux
 * $Source: ?/ADNCRM.Core/UI/AddEditItemPage.cs $
 * $log$
 * Revision 6 2010/08/06 19:56:29  christian.surieux
 *   Added Log to All cs files
 */

using System;
using System.IO;
using System.Configuration;
using System.Collections;
using System.Reflection;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Globalization;

using AddonNice.Core;
using AddonNice.Diagnostics;
using AddonNice.UI;
using AddonNice.UI.WebControls;
using AddonNice.Helpers;
using AddonNice.Security;
using AddonNice.Configuration;

using Trace2 = System.Diagnostics.Trace;

namespace AddonNice.UI
{
	/// <summary>
	/// AddEditItemPage inherits from AddonNice.UI.Page <br/>
	/// Used for add/edit pages<br/>
	/// Can be inherited
	/// </summary>
	public class AddEditItemPage : EditItemPage
	{

        protected AddEditItemPage() : base()
        {
        }

        protected AddEditItemPage(bool HasUpd,bool HasCancel,bool HasSaveClose,bool HasDelete) : base(HasUpd,HasCancel,HasSaveClose,HasDelete)
        {
        }
		/// <summary>
		/// Handles OnUpdate event
		/// </summary>
		/// <param name="e"></param>
		protected override void OnUpdate(ADNPageEventArgs e) 
		{
			// Verify that the current user has access to add in this module
			if ( Module == null || ( !PortalSecurity.IsUserInRoles(Module.AuthorizedAddRoles) && 
                !PortalSecurity.IsUserInRoles(Module.AuthorizedEditRoles)) )
				PortalSecurity.AccessDeniedEdit();
			base.OnUpdate(e);
		}


		/// <summary>
		/// Load settings
		/// </summary>
		protected override void LoadSettings()
        {		
            bool ModuleIsNull   =   ( Module == null );
            if ( PageTraceSwitch.Sw.TraceError )
                Trace2.WriteLine( string.Format(CultureInfo.InvariantCulture,"[V]AddEditItemPage LoadSettings EntityName: {0}, Module Is Null: {1}", EntityName, ModuleIsNull),PageTraceSwitch.Sw.Info);
			// Verify that the current user has access to edit this module
			if ( ModuleIsNull || ( !PortalSecurity.IsUserInRoles(Module.AuthorizedAddRoles) && !PortalSecurity.IsUserInRoles(Module.AuthorizedEditRoles)) )
				PortalSecurity.AccessDeniedEdit();
			base.LoadSettings();
		}
	}
}